package com.wolf.controller;

import com.wolf.pojo.Wl_order_refund;
import com.wolf.service.Wl_order_refundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@ComponentScan
public class Wl_order_refundController {
        @Autowired
    Wl_order_refundService wl_order_refundService;

    /**
     * 查询所有
     */
    @RequestMapping("wl_order_refund_getAll")
    public String getAll(ModelMap m){
        List<Wl_order_refund> list=wl_order_refundService.getAll();
        m.addAttribute("wl_order_refund_list",list);
        return "wl_order_refund";
    }

    /**
     *根据id查询
     */
    @RequestMapping("wl_order_refund_findBy")
    public String findBy(ModelMap m,String id){
        Wl_order_refund refund=wl_order_refundService.selectByPrimaryKey(id);
        m.addAttribute("refund",refund);
        return "wl_order_refund_findBy";
    }

    /**
     * 模糊查询
     */
    @RequestMapping("wl_order_refund_fuzzQuery")
    public String fuzzQuery(int fangshi,int zhuangtai,String tuihuoId,String beginTime,String endTime,ModelMap m,Wl_order_refund wl){

        List<Wl_order_refund> list=wl_order_refundService.fuzzQuery(fangshi,zhuangtai,tuihuoId,beginTime,endTime);
        m.addAttribute("wl_order_refund_list",list);
        return "wl_order_refund";
    }

    /**
     * 查询微信支付方式的所有信息
     */
    @RequestMapping("wl_order_refund_getWeixinAll")
    public String getWeixinAll(ModelMap m){
        List<Wl_order_refund> getWeixinAllList=wl_order_refundService.getWeixinAll();
        m.addAttribute("getWeixinAllList",getWeixinAllList);
        return "wl_order_refundWeixinAll";
    }

    /**
     * 微信支付模糊查询
     */
    @RequestMapping("wl_order_refund_getWeixinfuzzQuery")
        public String getWeixinfuzzQuery(String tuihuoId,String beginTime,String endTime,ModelMap m,Wl_order_refund wl){

            List<Wl_order_refund> getWeixinAllList=wl_order_refundService.WeixinfuzzQuery(tuihuoId,beginTime,endTime);
            m.addAttribute("getWeixinAllList",getWeixinAllList);
            return "wl_order_refundWeixinAll";
        }

    /**
     *选中修改退款状态
     */
    @RequestMapping("wl_order_refund_getUpdateRefundMoneyStatus")
    public String getUpdateRefundMoneyStatus(String[] id, RedirectAttributes redirectAttributes){
       for (String i:id)
            wl_order_refundService.updateWeixinRefundMoneyStatus(i);

        return "redirect:wl_order_refund_getWeixinAll";
    }
}
